package com.niuniu.order_consumer.util;

import com.niuniu.order_consumer.pojo.entity.OrderMessage;
import com.niuniu.order_consumer.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MQreceiver {
    @Autowired
    OrderService orderService;


    @RabbitListener(queues = "order_queue")
    public void receive(String message){
        OrderMessage orderMessage = JsonUtils.parseObject(message,OrderMessage.class);
        orderService.processOrder(orderMessage);
    }
}
